var ECLIPSE_FRAME_NAME = "ContentViewFrame";
var eclipseBuild = false;
var liveDocsBaseUrl = "http://livedocs.adobe.com/flex/3";
var liveDocsBookName = "langref";

var terms_HELPCFG = "PlatformASLR.helpcfg";

//splitter
var splitterActiveFlag = false ;
var splitterObj = false;
var h_splitterActiveFlag = false ;
var h_splitterObj = false;
var MIN_LEFT = 60;
var MIN_RIGHT = 200;
var MIN_TOP = 60;
var MIN_BOTTOM = 60;
var use_robohelp_behavior = false;
var agt=navigator.userAgent.toLowerCase();

/*Bug# 2765953 */
function HideEmptyRows(){
	var rowLinks = document.getElementsByName("rowLink");
	var i;
	var table = document.getElementById("tbl1");
	var len = table.rows.length;
	
	for(i=len-1;i!=0;i--){
		if(table.rows[i].getAttribute("name") == "rowLink"){
			if(table.rows[i].getElementsByTagName("td")[0].innerHTML.replace(/^\s+|\s+$/g,"") == ""){ 
				/*Deleting Description & Link row if Link row is empty*/
				/* Deleting (i+1) before (i) because otherwise index value would change */
				table.deleteRow(i+1);
				table.deleteRow(i);
				
			}
		}
	}
	
}

//Start: Bug#1325173
function alternate(id){
 	 HideEmptyRows();
 if(document.getElementsByTagName){  
   var table = document.getElementById(id);  
   var rows = table.getElementsByTagName("tr");
   var r1 = rows.length-1;  
    
    var scheme = "odd";
    var k = 0*1;
   for(i = 1; i < rows.length; i++){ 
           
 //manipulate rows
 
 if(scheme=="odd"){
       if((k*1)<(i*1) && i < rows.length - 3){
       rows[i].className = "even";
       k=1*i;
       if((i+1)<=rows.length && i < rows.length - 3){
       	   k=1*(i+1);
       	rows[k].className = "even";
       	scheme="even";
       }
       
       }
  }else{
  	  if((k*1)<(i*1) && i < rows.length - 3){
  	  rows[i].className = "odd";
  	  k=1*i;
  	  if(i!=1&&(i+1)<=rows.length && i < rows.length - 3){
  	  	  k=1*(i+1);
       	rows[k].className = "odd";
       	scheme="odd";
      }
      
      }
  }
 
 }
 }
}
//End: Bug#1325173


//Start: Bug#1899661
function noFrms(){ 
        var doc = parent.frames["classFrame"].location.href.substring(window.location.href.lastIndexOf("/")+1); 
        if(doc=="search.html"){ 
          var curLoc=window.top.location.href.split("?"); 
          var openFile; 
          if(curLoc[1]!=null){ 
            curLoc = curLoc[1].split("#"); 
            var search = curLoc[1];
            curLoc = curLoc[0].split("&amp;");       
            openFile = window.top.location.href.substring(0,window.top.location.href.lastIndexOf("?")+1); 
            openFile = openFile.substring(0,openFile.lastIndexOf("/")+1)+"search.html#"+search;
          }
          else{ 
            curLoc[0]="index.html"; 
            openFile = window.top.location.href.substring(0,window.top.location.href.lastIndexOf("/")+1)+curLoc[0];
          } 
          top.location=openFile; 
        }else{
          top.location=top.classFrame.location;
        }
      } 

function searchfunctionsubmit(baseref){
       var searchStr=document.getElementById('search-livedocs').value;
       window.location=baseRef+"search.html"+"###"+searchStr;
        }

function submitStandAloneSearchValue(){
	var searchStr=document.getElementById('search-livedocs').value;
          loadClassFrame("search.html?search=" +searchStr);
          document.getElementById('subTitle').childNodes.item(0).data = "Search Results";
          return false; 
}

function submitValue(title,url,label,site,loc) {
var title=title;
var searchStr=document.getElementById('search-livedocs').value;
title = encodeURIComponent(encodeURIComponent(title));
	  var ptn = /\./;
	  if (ptn.test(title)) {
	  	title = title.replace(ptn, "%252E"); 
	  }  
        if(document.getElementById('checkBoxId').checked){
        top.location.href="http://"+url+"?q=" + escapeSpecialChars(searchStr)
+"&loc="+loc
+"&hl="+loc
+"&lbl="+label
+"&go=Search"
+"&self=1"
+"&site="+site;
} 
        else{ 
top.location.href="http://"+url+"?q=" + escapeSpecialChars(searchStr)
+"&loc="+loc
+"&hl="+loc
+"&lbl="+label
+"&go=Search"
+"&self=1";
} 
          document.getElementById('subTitle').childNodes.item(0).data = "";
          return false; 
}

function escapeSpecialChars(str){
	str = str.replace(/%/g,"%25");
	str = str.replace(/!/g,"%21");
	str = str.replace(/@/g,"%40");
	str = str.replace(/#/g,"%23");
	str = str.replace(/\$/g,"%24");
	str = str.replace(/&/g,"%26");
	str = str.replace(/\(/g,"%28");
	str = str.replace(/\)/g,"%29");
	str = str.replace(/\+/g,"%2B");
	str = str.replace(/\[/g,"%5B");
	str = str.replace(/\]/g,"%5D");
	str = str.replace(/:/g,"%3A");
	str = str.replace(/;/g,"%3B");
	str = str.replace(/'/g,"%27");
	str = str.replace(/\//g,"%2F");
	str = str.replace(/\\/g,"%5C");
	str = str.replace(/,/g,"%2C");
	str = str.replace(/\s+/g,"+");
	return str;
}

function addIonComments(label)
{
	var loc = getLangName();
	function getLangName() {		
	var lang = "en-us";		
	var metaElements = document.all ?
	document.all.tags('meta') :
	document.getElementsByTagName ?
	document.getElementsByTagName ('meta') : new Array();

	var metaLangVals = new Array();
	var i = 0;

	for (var m = 0; m < metaElements.length; m++) {	    
	if (metaElements[m].name == "lang") {	      
	lang = metaElements[m].content;	      
	break;	    
	}		
	}		

	var ptn = /(..)-(..)/;		

	if (ptn.test(lang)) {			
	var countryCode = lang.replace(ptn, "$1");			
	var languageCode = lang.replace(ptn, "$2");			
	lang = countryCode + "_" + languageCode.toUpperCase();		

	}	  
	return lang;	
	}		

	var commentsContainer = "ionComHere";	

	ionComAddLoadEvent(function() {		
	var thisURL = encodeURIComponent(window.location);		
	var resource = thisURL.replace(new RegExp(/%23(.*)/),"");		
	ionComments.setup(resource, loc, commentsContainer, { siteArea: 'help', productLabel: +label });	})	
}

function gotoHome(linkURL) 
{
	var windowURL= window.location.href;

	var value = windowURL.replace(/title-bar\.html.*/,linkURL );

 	if (value != null) { 
		parent.top.location = value;
	}
}

function findObject(objId) {

    if (document.getElementById)
        return document.getElementById(objId);

    if (document.all)
        return document.all[objId];
}

function isEclipse() {
    return eclipseBuild
}

		
function configPage() {

	var d=document.location.href.toString();
	parameter_index = d.lastIndexOf('?');
    var args = '';
	if (parameter_index != -1) {
		args=d.substring(parameter_index+1,d.length);
	}
	//Start: Bug#1882766 
	if (args.indexOf('#') != -1){
		args = args.replace(new RegExp(/#/),"%23");
	}
	else if (args.indexOf('%23') != -1){
		args = args.replace(new RegExp(/%23/),"#");
	}
	
    setRowColorsInitial(true, "Property");
    setRowColorsInitial(true, "Method");
    setRowColorsInitial(true, "ProtectedMethod");   
    setRowColorsInitial(true, "Event");
    setRowColorsInitial(true, "Style");
    setRowColorsInitial(true, "SkinPart");
    setRowColorsInitial(true, "SkinState");
    setRowColorsInitial(true, "Constant");

    if (isEclipse()) {
        if (window.name != "classFrame")
        {
            var localRef = window.location.href.indexOf('?') != -1 ? window.location.href.substring(0, window.location.href.indexOf('?')) : window.location.href;

	    var rootdir = "doc/";
            localRef = localRef.substring(localRef.indexOf(rootdir) + rootdir.length);

            if (window.location.search != "")
                localRef += ("#" + window.location.search.substring(1));

            window.location.replace(baseRef + "frames.html?" + localRef);
            return;
        }
        else
        {
		setStyle(".eclipseBody", "display", "block");
            if (window.location.hash != "")
                window.location.hash=window.location.hash.substring(1);
        }
    }
 
    try{
	    getFilterContent(filter_file,args);
    }catch(e)
    {
    }
    
    //have to wait till dom loads
    if (agt.indexOf("adobe help viewer 2") != -1 || agt.indexOf("community help client") != -1) {
    use_robohelp_behavior = true;
    document.getElementById("gsa").style.display = "none";
}

}

function loadFrames(classFrameURL, classListFrameURL) {
    var classListFrame = findObject("classListFrame");
    if(classListFrame != null && classListFrameContent!='')
        classListFrame.document.location.href=classListFrameContent;

    if (isEclipse()) {
        var contentViewFrame = findObject(ECLIPSE_FRAME_NAME);
        if (contentViewFrame != null && classFrameURL != '')
            contentViewFrame.document.location.href=classFrameURL;
    }
    else {
        var classFrame = findObject("classFrame");
        if(classFrame != null && classFrameContent!='')
            classFrame.document.location.href=classFrameContent;
    }
}

function showTitle(title) {
    if (!isEclipse())
        top.document.title = title;
}

function loadClassFrame(classFrameURL) {
    if (parent.frames["classFrame"] != null) {
        parent.frames["classFrame"].location = classFrameURL;
    }
    else if (parent.frames["packageFrame"] != null) {
        if (parent.frames["packageFrame"].frames["classFrame"] != null) {
            parent.frames["packageFrame"].frames["classFrame"].location = classFrameURL;
        }
    }
}

function loadClassListFrame(classListFrameURL) {
    if (parent.frames["classListFrame"] != null) {
        parent.frames["classListFrame"].location = classListFrameURL;
    }
    else if (parent.frames["packageFrame"] != null) {
        if (parent.frames["packageFrame"].frames["classListFrame"] != null) {
            parent.frames["packageFrame"].frames["classListFrame"].location = classListFrameURL;
        }
    }
}

function loadPage(relativeURLFromBase) {
     document.location.href = baseRef+relativeURLFromBase;
}

function gotoLiveDocs(primaryURL, secondaryURL, locale) {
        if (locale == "en-us" || locale == "en_us" || locale == "en_US") {
             locale = "";
        } 
        else {
              locale = "_" + locale.substring(3);
        }
    var url = liveDocsBaseUrl + locale + "/" + liveDocsBookName + "/frames.html?" + primaryURL;
    if (secondaryURL != null && secondaryURL != "")
        url += ("&" + secondaryURL);

    window.open(url, "mm_livedocs", "menubar=1,toolbar=1,status=1,scrollbars=1,resizable=yes");
}

function findTitleTableObject(id)
{
    if (isEclipse())
        return parent.titlebar.document.getElementById(id);
    else if (top.titlebar)
        return top.titlebar.document.getElementById(id);
    else
        return document.getElementById(id);
}

function titleBar_setSubTitle(title)
{
    if (isEclipse() || top.titlebar)
        findTitleTableObject("subTitle").childNodes.item(0).data = title;
}

function titleBar_setSubNav(showConstants,showProperties,showStyles,showSkinPart,showSkinState,showEffects,showEvents,showConstructor,showMethods,showExamples,
                showPackageConstants,showPackageProperties,showPackageFunctions,showInterfaces,showClasses,showPackageUse)
{
	findTitleTableObject("propertiesLink").style.display = showProperties ? "inline" : "none";
	findTitleTableObject("propertiesBar").style.display = (showProperties && (showPackageProperties || showConstructor || showMethods || showPackageFunctions || showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("packagePropertiesLink").style.display = showPackageProperties ? "inline" : "none";
	findTitleTableObject("packagePropertiesBar").style.display = (showPackageProperties && (showConstructor || showMethods || showPackageFunctions || showEvents || showStyles || showConstants || showEffects || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("constructorLink").style.display = showConstructor ? "inline" : "none";
	findTitleTableObject("constructorBar").style.display = (showConstructor && (showMethods || showPackageFunctions || showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("methodsLink").style.display = showMethods ? "inline" : "none";
	findTitleTableObject("methodsBar").style.display = (showMethods && (showPackageFunctions || showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("packageFunctionsLink").style.display = showPackageFunctions ? "inline" : "none";
	findTitleTableObject("packageFunctionsBar").style.display = (showPackageFunctions && (showEvents || showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("eventsLink").style.display = showEvents ? "inline" : "none";
	findTitleTableObject("eventsBar").style.display = (showEvents && (showStyles || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("stylesLink").style.display = showStyles ? "inline" : "none";
	findTitleTableObject("stylesBar").style.display = (showStyles && (showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("SkinPartLink").style.display = showSkinPart ? "inline" : "none";
	findTitleTableObject("SkinPartBar").style.display = (showSkinPart && (showSkinState || showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("SkinStateLink").style.display = showSkinState ? "inline" : "none";
	findTitleTableObject("SkinStateBar").style.display = (showSkinState && (showEffects || showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("effectsLink").style.display = showEffects ? "inline" : "none";
	findTitleTableObject("effectsBar").style.display = (showEffects && (showConstants || showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("constantsLink").style.display = showConstants ? "inline" : "none";
	findTitleTableObject("constantsBar").style.display = (showConstants && (showPackageConstants || showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("packageConstantsLink").style.display = showPackageConstants ? "inline" : "none";
	findTitleTableObject("packageConstantsBar").style.display = (showPackageConstants && (showInterfaces || showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("interfacesLink").style.display = showInterfaces ? "inline" : "none";
	findTitleTableObject("interfacesBar").style.display = (showInterfaces && (showClasses || showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("classesLink").style.display = showClasses ? "inline" : "none";
	findTitleTableObject("classesBar").style.display = (showClasses && (showPackageUse || showExamples)) ? "inline" : "none";
	findTitleTableObject("packageUseLink").style.display = showPackageUse ? "inline" : "none";
	findTitleTableObject("packageUseBar").style.display = (showPackageUse && showExamples) ? "inline" : "none";
	findTitleTableObject("examplesLink").style.display = showExamples ? "inline" : "none";
}

function titleBar_gotoClassFrameAnchor(anchor)
{
    if (isEclipse())
        parent.classFrame.location = parent.classFrame.location.toString().split('#')[0] + "#" + anchor;
    else
        location = location.toString().split('#')[0] + "#" + anchor;
}

function setMXMLOnly() 
{
    if (getCookie("showMXML") == "false")
    {
        toggleMXMLOnly();
    }
}

function toggleMXMLOnly() 
{
    var mxmlDiv = findObject("mxmlSyntax");
    var mxmlShowLink = findObject("showMxmlLink");
    var mxmlHideLink = findObject("hideMxmlLink");
    if (mxmlDiv && mxmlShowLink && mxmlHideLink)
    {
        if (mxmlDiv.style.display == "none")
        {
            mxmlDiv.style.display = "block";
            mxmlShowLink.style.display = "none";
            mxmlHideLink.style.display = "inline";
            setCookie("showMXML","true", new Date(3000,1,1,1,1), "/", document.location.domain);
        }
        else
        {
            mxmlDiv.style.display = "none";
            mxmlShowLink.style.display = "inline";
            mxmlHideLink.style.display = "none";
            setCookie("showMXML","false", new Date(3000,1,1,1,1), "/", document.location.domain);
        }
    }
}

function showHideInherited()
{   
    setInheritedVisible(getCookie("showInheritedConstant") == "true", "Constant");
    setInheritedVisible(getCookie("showInheritedProtectedConstant") == "true", "ProtectedConstant");
    setInheritedVisible(getCookie("showInheritedProperty") == "true", "Property");
    setInheritedVisible(getCookie("showInheritedProtectedProperty") == "true", "ProtectedProperty");
    setInheritedVisible(getCookie("showInheritedMethod") == "true", "Method");
    setInheritedVisible(getCookie("showInheritedProtectedMethod") == "true", "ProtectedMethod");
    setInheritedVisible(getCookie("showInheritedEvent") == "true", "Event");
    setInheritedVisible(getCookie("showInheritedcommonStyle") == "true", "commonStyle");
	setInheritedVisible(getCookie("showInheritedsparkStyle") == "true", "sparkStyle");
	setInheritedVisible(getCookie("showInheritedhaloStyle") == "true", "haloStyle");
	setInheritedVisible(getCookie("showInheritedmobileStyle") == "true", "mobileStyle");
    setInheritedVisible(getCookie("showInheritedSkinPart") == "true", "SkinPart");
    setInheritedVisible(getCookie("showInheritedSkinState") == "true", "SkinState");
    setInheritedVisible(getCookie("showInheritedEffect") == "true", "Effect");
}


function setInheritedVisible(show, selectorText)
{
	try{
		if (document.styleSheets[0].cssRules != undefined)
		{
			var rules = document.styleSheets[0].cssRules;
			for (var i = 0; i < rules.length; i++)
			{
			  
				if (rules[i].selectorText == ".hideInherited" + selectorText)
					rules[i].style.display = show ? "" : "none";
				   
				if (rules[i].selectorText == ".showInherited" + selectorText)
					rules[i].style.display = show ? "none" : "";
			}
		}
		else
		{
			document.styleSheets[0].addRule(".hideInherited" + selectorText, show ? "display:inline" : "display:none");
			document.styleSheets[0].addRule(".showInherited" + selectorText, show ? "display:none" : "display:inline");
		}
	}catch(e){
		document.styleSheets[0].addRule(".hideInherited" + selectorText, show ? "display:inline" : "display:none");
		document.styleSheets[0].addRule(".showInherited" + selectorText, show ? "display:none" : "display:inline");
	}
    setCookie("showInherited" + selectorText, show ? "true" : "false", new Date(3000,1,1,1,1), "/", document.location.domain);
    setRowColors(show, selectorText);
}

function setRowColors(show, selectorText)
{
    var rowColor = "#F2F2F2";
    var table = findObject("summaryTable" + selectorText);

    if (table != null)
    {
        var rowNum = 0;
        for (var i = 1; i < table.rows.length; i++)
        {
            if (table.rows[i].className.indexOf("hideInherited") == -1 || show)
            {
                if(table.rows[i].style.display.indexOf('none') == -1)
                {
                    rowNum++;
                    table.rows[i].bgColor = (rowNum % 2 == 0) ? rowColor : "#FFFFFF";
                }
            }           
        }
    }
}

function setRowColorsInitial(show, selectorText)
{
    var rowColor = "#F2F2F2";
    var table = findObject("summaryTable" + selectorText);

    if (table != null)
    {
        var rowNum = 0;

        for (var i = 1; i < table.rows.length; i++)
        {
            if (table.rows[i].className.indexOf("hideInherited") == -1 && !show)
            {
                rowNum++;
                table.rows[i].bgColor = (rowNum % 2 == 0) ? rowColor : "#FFFFFF";
            }           
        }
    }
}

function setStyle(selectorText, styleName, newValue)
{
	try{
		if (document.styleSheets[0].cssRules != undefined)
		{
			var rules = document.styleSheets[0].cssRules;

			for (var i = 0; i < rules.length; i++)
			{
				if (rules[i].selectorText == selectorText)
				{
					rules[i].style[styleName] = newValue;
				   break;
				}
			}
		}

		else
		{
			document.styleSheets[0].addRule(selectorText, styleName + ":" + newValue);
		}
	}catch(e){
		document.styleSheets[0].addRule(selectorText, styleName + ":" + newValue);
	}
}

  function setView(view){
        var expire = new Date();
        expire.setDate(expire.getDate()+90); // Cookie expires after 90 days
 	var pathDomainString="path=/;";
	if(navigator.userAgent.indexOf("Firefox")!=-1)
	{
	// code for possible use with FF when it gets working
		var theHost=document.location.hostname;
		pathDomainString = "path=/;domain="+theHost+";";		
	}

        document.cookie = "asdocs_view=" + view + ";"+ pathDomainString+"expires=" + expire.toGMTString();
    }   
    
var packagesLoaded = false, classesLoaded = false;
function loadPackagesList(page_request){
	document.getElementById("packagelist").innerHTML=page_request.responseText;
	if(buildType != "jslr"){
		document.getElementById("pkg_searchbox").defaultValue = qsearchBoxLabel;
		var IECheck = navigator.userAgent.search("MSIE");
		var IEVersion = getInternetExplorerVersion();
		if(IECheck>0 && IEVersion < 9){
			document.getElementById("pkg_searchspan").style.display = "none";
		}else{
			document.getElementById("pkg_searchspan").style.display = "";
		}
		changeQSearchboxWidth();
	}
	packagesLoaded = true;  
	try{
	    if(classesLoaded) 
		    doFilterStateChange1();
	    }catch(e)
	    {
	    }
	setTimeout("restorePackageListScrollTop()", 1000);
}

function loadClassesList(page_request){
	if(buildType == "jslr"){
		document.getElementById("classlist").innerHTML=page_request.responseText;
	}else{
		document.getElementById("classlistoutline").innerHTML=page_request.responseText;
		document.getElementById("cls_searchbox").defaultValue = qsearchBoxLabel;
		var IECheck = navigator.userAgent.search("MSIE");
		var IEVersion = getInternetExplorerVersion();
		if(IECheck>0 && IEVersion < 9){
			document.getElementById("cls_searchspan").style.display = "none";
		}else{
			document.getElementById("cls_searchspan").style.display = "";
		}
		if(getCookie("showAllClasses")=="yes"){
			allClassesLoaded = true;
			var clbox = document.getElementById("cls_searchbox");
			if(clbox.style.display != "none" && clbox.value != clbox.defaultValue && clbox.value != ""){
				setTimeout("clsSearchOnKeyUp1()",500);
			}
		}
		changeQSearchboxWidth();
	}
	classesLoaded = true;    
	try{
	    if(packagesLoaded) 
		    doFilterStateChange1();
	    }catch(e)
	    {
	    }
	setTimeout("restoreClassListScrollTop()", 1000);
}

function loadClassesList2(page_request){
	document.getElementById("classlist").innerHTML=page_request.responseText;
	
	classesLoaded = true;    
	try{
	    if(packagesLoaded) 
		    doFilterStateChange1();
	    }catch(e)
	    {
	    }
	setTimeout("restoreClassListScrollTop()", 1000);
}

function init()
{
   //if we want it showing, then we need to cause it to open
	document.getElementById("maincontainer").style.display = "";
	//the follow init process need to put into a timeout
	//otherwise the list can not be correctly displayed in IE7
	setTimeout("init1()", 0);
}

function init1()
{
	restoreSplitterPos();
	restoreHSplitterPos();
   if (getCookie("asdocs_view") == "showtoc")
	     showHideTOC(true);
	else
		showHideTOC(false);
	
	if(getCookie("showAllClasses")==""){
		setCookie("showAllClasses", "no", new Date(3000,1,1,1,1), "/", document.location.domain);
	}
	
	if(buildType.indexOf('jslr')== -1)
		ajaxGet(baseRef + "package-list.html", loadPackagesList);
	
	if(buildType.indexOf('jslr')!=-1){
		ajaxGet(baseRef+"all-classes.html", loadClassesList);
	}else if (location.href.indexOf("?allClasses=1") > 0) {
		if(getCookie("showAllClasses")=="yes"){
			ajaxGet(baseRef+"all-classes.html", loadClassesList);
		}else{
			ajaxGet(baseRef+"all-classes-A.html", loadClassesList);
		}
	} else if ((location.href.indexOf("mxml-tag-detail.html") > 0) 
		|| (baseRef == "../" && (location.href.indexOf("/mxml/") > 0))) {
		ajaxGet(baseRef+"mxml-tags.html", loadClassesList);
	} else if( (baseRef=='') && (location.href.indexOf("package-detail.html") > 0 || location.href.indexOf("package.html") > 0) ){
		ajaxGet(baseRef + "class-list.html", loadClassesList2);
	} else if (baseRef=='' || baseRef=='./') {
	
		if(getCookie("showAllClasses")=="yes"){
			ajaxGet(baseRef+"all-classes.html", loadClassesList);
		}else{
			ajaxGet(baseRef+"all-classes-A.html", loadClassesList);
		}
		
	} else if(location.href.indexOf("package-detail")>0){
		ajaxGet("class-list.html",loadClassesList2);
	}else if(getCookie("showAllClassesList")=="yes"){
		if(getCookie("showAllClasses")=="yes"){
			ajaxGet(baseRef+"all-classes.html",loadClassesList);
		}else{
			ajaxGet(baseRef+"all-classes-A.html",loadClassesList);
		}
	}else {
		ajaxGet("class-list.html", loadClassesList2);
	}
	configPage();
	
	scrollToNameAnchor();
	
	/*Added by Madhur. Page was not scrolling to the anchor*/
	if(window.location.href.indexOf("#") != -1){
	   
	    document.location = window.location.href;
	}
}

/* needed for IPH builds used offline in CHC */
function scrollToNameAnchor() 
{
	var nameAnchor = window.location.href;
	var value = nameAnchor.split("nameAnchor=");
	
	if (value[1] != null) { 
		document.location =value[0]+"#"+ value[1];
	}
}


function ajaxGet(url, responseHandler)
{
	var page_request = false;

	if (window.XMLHttpRequest && !(window.ActiveXObject && window.location.protocol == "file:")) { 
                // use this only if available, and not using IE on a local filesystem
		page_request = new XMLHttpRequest();
        }
	else if (window.ActiveXObject) { // older versions of IE, or IE on a local filesystem
		try {
			page_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			try{
				page_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){
			}
		}
	}
	else {
		alert("Your browser does not support XMLHTTP.");
		return false;
	}

	
	page_request.onreadystatechange=function() {
		if(page_request.readyState==4) {
                        // on local machines the status for success is 0. on web servers it is 200
			if(page_request.status==200 || page_request.status==0) {
				responseHandler(page_request);
			}
		}
	}
	
	page_request.open('GET', url, true);
	page_request.send(null);
}

function showHideTOC(showTOC)
{
	var toc = document.getElementById("toc");
	var splitter = document.getElementById("splitter");
	var content = document.getElementById("content");
	var plist = document.getElementById("packagelist");
	var h_splitter = document.getElementById("h_splitter");
	var clist = document.getElementById("classlist");
	var showtoc = document.getElementById("showtoc");
	var hidetoc = document.getElementById("hidetoc");
	if(toc)
	{			
		if(!showTOC)
		{
			eval("toc.style.display =''");
			eval("splitter.style.display =''");
			if(h_splitter)
				eval("h_splitter.style.display =''");
			content.style.left ='6px';
			eval("showtoc.style.display =''");
			eval("hidetoc.style.display ='none'");
			setView("hidetoc");
		}
		else
		{
			eval("toc.style.display ='inline'");
			eval("splitter.style.display ='inline'");
			toc.style.width = (splitter.offsetLeft - 20) + 'px';
			content.style.left = (splitter.offsetLeft + 10) + 'px';
			//doesn't exist for jslr build
			if(h_splitter)
			{
				eval("h_splitter.style.display ='inline'");
				plist.style.height = (h_splitter.offsetTop - 10) + 'px';
				clist.style.top = (h_splitter.offsetTop + 4) + 'px';
			}
			eval("showtoc.style.display ='none'");
			eval("hidetoc.style.display =''");
			setView("showtoc");
		}
	}
}

		  
function splitterMouseDown(event, obj){
	if(!splitterActiveFlag){
		if(obj.setCapture)
			obj.setCapture();
		else {
			document.addEventListener('mouseup', splitterMouseUp, true);
			document.addEventListener('mousemove', splitterMouseMove, true);
			event.preventDefault();
		}
		
		splitterActiveFlag = true ;
		splitterObj = obj;
	}
}
function changeQSearchboxWidth(){
	if(getInternetExplorerVersion() != "7"){ /* #2923491 - workaround for ie7 issue */
		spObj = document.getElementById("splitter");
		var pkgSbox = document.getElementById("pkg_searchbox");
		var clSbox = document.getElementById("cls_searchbox");
		if(spObj.offsetLeft>220 && spObj.offsetLeft<265){
			if(pkgSbox != null){
				pkgSbox.style.width = spObj.offsetLeft-138+"px";
			}
			if(clSbox != null){
				clSbox.style.width = spObj.offsetLeft-138+"px";
			}
		}
		if(spObj.offsetLeft>=265){
			if(pkgSbox != null){
				pkgSbox.style.width = "127px";
			}
			if(clSbox != null){
				clSbox.style.width = "127px";
			}
		}
		if(spObj.offsetLeft<=220){
			if(pkgSbox != null){
				pkgSbox.style.width = "82px";
			}
			if(clSbox != null){
				clSbox.style.width = "82px";
			}
		}
	}
}

function splitterMouseUp(event){
	if(splitterActiveFlag){
		var objLeft = document.getElementById("toc") ; 
		var objRight = document.getElementById("content") ;
		changeQSearchboxWidth();
		objLeft.style.width = (splitterObj.offsetLeft - 20) + "px" ;
		objRight.style.left = (splitterObj.offsetLeft + 10) + "px" ; 
		
		if(splitterObj.releaseCapture)
			splitterObj.releaseCapture();
		else {
			document.removeEventListener('mouseup', splitterMouseUp, true);
			document.removeEventListener('mousemove', splitterMouseMove, true);
			event.preventDefault();
		}
		
		splitterActiveFlag = false ;
		saveSplitterPos();
	}

}

function splitterMouseMove(event){
	if(splitterActiveFlag){
		if (event.clientX >= MIN_LEFT && event.clientX <= document.documentElement.clientWidth - MIN_RIGHT) {
			splitterObj.style.left = event.clientX + "px" ;
			if(!splitterObj.releaseCapture) {
				event.preventDefault();
			}
		}
	}
}

function h_splitterMouseDown(event, obj){
	if(!h_splitterActiveFlag){
		if(obj.setCapture)
			obj.setCapture();
		else {
			document.addEventListener('mouseup', h_splitterMouseUp, true);
			document.addEventListener('mousemove', h_splitterMouseMove, true);
			event.preventDefault();
		}
		
		h_splitterActiveFlag = true ;
		h_splitterObj = obj;
	}
}
function h_splitterMouseUp(event){
	if(h_splitterActiveFlag){
		var objTop = document.getElementById("packagelist") ; 
		var objBottom = document.getElementById("classlist") ;
		objTop.style.height = (h_splitterObj.offsetTop - 10) + "px" ;
		objBottom.style.top = (h_splitterObj.offsetTop + 4) + "px" ; 
		
		if(h_splitterObj.releaseCapture)
			h_splitterObj.releaseCapture();
		else {
			document.removeEventListener('mouseup', h_splitterMouseUp, true);
			document.removeEventListener('mousemove', h_splitterMouseMove, true);
			event.preventDefault();
		}
		
		h_splitterActiveFlag = false ;
		saveHSplitterPos();
	}

}

function h_splitterMouseMove(event){
	if(h_splitterActiveFlag){
		var top = event.clientY - document.getElementById("maincontainer").offsetTop;
		if (top >= MIN_TOP && event.clientY <= document.documentElement.clientHeight - MIN_BOTTOM) {
			h_splitterObj.style.top = top + "px" ;
			if(!h_splitterObj.releaseCapture) {
				event.preventDefault();
			}
		}
	}
}

/*----------------------------------------------------- helper JS -----------------------------------------------------*/
function setStyle(theObj, styleName, styleValue, priority) {
  var bSuccess = false;

  try {
    if (theObj.style && theObj.style.setProperty) {
      theObj.style.setProperty(styleName, styleValue,priority);
      bSuccess = true;
    }
  } catch (ex) {
    alert('exception caught setting style: ' + ex.message); // cannot do anything try the next method
  }
  if (!bSuccess) {
    try {
      theObj.style[styleName] = styleValue;
      bSuccess = true;
    } catch (exNext) {
      alert('exception caught setting direct style: ' + exNext.message); // cannot do anything
    }
  }
  return bSuccess;
} // end of setStyle

// global to store the item to be focused
gFocusItem =null;
gLastFocusItem = null;
function doFocus()
{
  if (gFocusItem != null) {
    gFocusItem.focus();
    if (gLastFocusItem && gLastFocusItem.className == 'item focus')
      gLastFocusItem.className = 'item';
    if (gFocusItem && gFocusItem.className == 'item')
      gFocusItem.className = 'item focus';
    gLastFocusItem = gFocusItem;
    gFocusItem=null;
  }
}

// Adobe Help versions pod
var ahpodjs = "/en_US/shared/ahpods/AHPod.js";
document.write('<script src="' + ahpodjs + '"type="text/javascript" language="Javascript" charset="UTF-8"></scr'+'ipt>');

function savePackageListScrollTop() {
	var packageList = document.getElementById("packagelist");
	if (packageList) {
		setCookie("packageListScrollTop",packageList.scrollTop, new Date(3000,1,1,1,1), "/", document.location.domain);
		setCookie("classListScrollTop",0, new Date(3000,1,1,1,1), "/", document.location.domain);
	}
}

function saveClassListScrollTop() {
	var classList = document.getElementById("classlist");
	if (classList)
		setCookie("classListScrollTop",classList.scrollTop, new Date(3000,1,1,1,1), "/", document.location.domain);
}

function restorePackageListScrollTop() {
	var packageListScrollTop = getCookie("packageListScrollTop");
	if(packageListScrollTop)
		document.getElementById("packagelist").scrollTop = packageListScrollTop;
}

function restoreClassListScrollTop() {
	var classListScrollTop = getCookie("classListScrollTop");
	if(classListScrollTop)
		document.getElementById("classlist").scrollTop = classListScrollTop;
}
	
function saveSplitterPos() {
	var splitter = document.getElementById("splitter");
	if (splitter)
		setCookie("splitterPosition",splitter.offsetLeft, new Date(3000,1,1,1,1), "/", document.location.domain);
}

function restoreSplitterPos() {
	var splitterPosition = getCookie("splitterPosition");
	if(splitterPosition)
		document.getElementById("splitter").style.left = splitterPosition + "px";
}

function saveHSplitterPos() {
	var h_splitter = document.getElementById("h_splitter");
	if (h_splitter)
		setCookie("h_splitterPosition",h_splitter.offsetTop, new Date(3000,1,1,1,1), "/", document.location.domain);
}

function restoreHSplitterPos() {
	var h_splitter = document.getElementById("h_splitter");
	if (h_splitter) {
		var h_splitterPosition = getCookie("h_splitterPosition");
		if(h_splitterPosition)
			h_splitter.style.top = h_splitterPosition + "px";
	}
}

function setHrf(obj){
	var title = obj.title;
	var patt = new RegExp("./");
	if(patt.test(title)){
		obj.href = baseRef + title;
	}else{
		title = title.replace(/\./g, "/");
		obj.href=baseRef + title + '.html';
	}
}
/*This function is to save scroll when link is clicked*/
function svScrl(obj){
	setCookie("showAllClassesList","yes",new Date(3000,1,1,1,1),"/",document.location.domain);
	setHrf(obj);
	saveClassListScrollTop();
}

/*For JSLR */
function setHrfJSLR(obj){
	var title = obj.title;
	title = title.replace(/\./g, "/");
	if(title.search("\\(\\)") > 0){
		titleSub = title.substr(title.lastIndexOf("/")+1);
		title = title.replace(titleSub,"package.html#"+titleSub);
	}else{
		title = title + ".html";
	}
	obj.href = baseRef + title;
}
function svScrlJSLR(obj){
	setHrfJSLR(obj);
	saveClassListScrollTop();
}

var loadAllClassesRan = 0;
var allClassesLoaded =  false;
function saveAllClassesView(arg){
	if(arg=="more"){
			ajaxGet(baseRef+"all-classes.html", loadClassesList);
			setCookie("showAllClasses", "yes", new Date(3000,1,1,1,1), "/", document.location.domain);
			loadAllClassesRan = 1;			
	}else{
			ajaxGet(baseRef+"all-classes-A.html", loadClassesList);
			setCookie("showAllClasses", "no", new Date(3000,1,1,1,1), "/", document.location.domain);
			allClassesLoaded = false;
			loadAllClassesRan = 0;			
	}
}
/* showAllClassesList cookie is set to "no" when you are navigating inside packages */
function clearAllClassesListCookie(){
	setCookie("showAllClassesList","no",new Date(3000,1,1,1,1),"/",document.location.domain);
}

//************Start Pkg Quick Search*************//
function quickFilterPackages(){
	var term = document.getElementById("pkg_searchbox").value;
	var pkg = document.getElementById("packagelist");
	var x = pkg.getElementsByTagName("a");
	term = term.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
	var patt1 = new RegExp(term,"i");
	var foundPkgCount=0;
	for(i=0;i<x.length;i++){
		var pstr;
		if(x[i].textContent){
			pstr = x[i].textContent.match(patt1);
		}else{
			pstr = x[i].innerText.match(patt1);
		}
		
		if(x[i].className == "noqsearch"){
			x[i].style.display = "none";
		}else if(x[i].id == "pkg_name"){
			//dont filter package name
		}else if(pstr != null && pstr.length>0 && x[i].parentNode.parentNode.style.display != "none"){
			foundPkgCount++;
			var iterm = x[i].innerHTML;
			x[i].innerHTML = iterm.replace(pstr[0],"<span class='highlightText'>"+pstr[0]+"</span>");
		}else{
			if(x[i].id == "pkg_name" || x[i].id == "clear_search"){
				//x[i].style.display = "";
			}else{
				x[i].style.display = "none";
			}
		}
	}
	if(foundPkgCount == 0){
		var txtdoc = document.getElementById("pkg_txtMsg");
		if(txtdoc == null){
			var aPkg = document.createElement("div");
			aPkg.id = "pkg_txtMsg";
			aPkg.innerHTML = qsearchText;
			bPkg = document.getElementById("packagelist");
			bPkg.appendChild(aPkg);
		}
	}
		
}
function pkgSearchBoxOnFocus(){
	var inputDiv = document.getElementById("pkg_searchbox");
	if(inputDiv.value==inputDiv.defaultValue){
		inputDiv.value='';
		inputDiv.style.color='rgb(0, 0, 0)';
	}
}
function pkgSearchOnKeyUp(){
	var inputDiv = document.getElementById("pkg_searchbox");
	if(inputDiv.value==''){
		document.getElementById('pkg_clear_search').className = 'search_inactive';
	}else{
		document.getElementById('pkg_clear_search').className = 'search_active';
	}
	var len = document.getElementById("pkg_searchbox").value.length;
	if(len>=2){
		pkgClearHighlight();
		quickFilterPackages();
	}else{
		pkgClearHighlight();
	}
}
function pkgSearchBoxOnBlur(){
	var inputDiv = document.getElementById("pkg_searchbox");
	if(inputDiv.value==''){
		inputDiv.value=inputDiv.defaultValue;
		inputDiv.style.color='rgb(170, 170, 170)';
		document.getElementById('pkg_clear_search').className='search_inactive';
	}
}
function pkgClearSearchButton(){
	document.getElementById("pkg_searchbox").value='';
	document.getElementById("pkg_searchbox").focus();
	pkgClearHighlight();
	document.getElementById('pkg_clear_search').className = 'search_inactive';
}
function pkgClearHighlight(){
	var pkg = document.getElementById("packagelist");
	x = [];
	var tNode = document.getElementById("pkg_txtMsg");
	if( document.getElementById("pkg_txtMsg") != null){
		pNode = document.getElementById("packagelist");
		pNode.removeChild(tNode);
	}
		
	if(navigator.userAgent.search("MSIE") >=0){
		xtemp = pkg.getElementsByTagName("span");
		j=0;
		for(i=0;i<xtemp.length;i++){
			if(xtemp[i].className == "highlightText"){
				x[j] = xtemp[i];
				j++;
			}
		}
		for(i=0;i<x.length;i++){
			y = x[i].parentNode;
			z = x[i].innerHTML;
			txtNode = document.createTextNode(z);
			x[i].appendChild(txtNode);
			y.replaceChild(txtNode,x[i]);
		}
	}else{
		x = pkg.getElementsByClassName("highlightText");
		while(x.length>0){
			y = x[0].parentNode;
			z = x[0].innerHTML;
			txtNode = document.createTextNode(z);
			x[0].appendChild(txtNode);
			y.replaceChild(txtNode,x[0]);
		}
	}
	
	//making all the anchor tags visible
	var alinks = pkg.getElementsByTagName("a");
	for(i=0;i<alinks.length;i++){
		alinks[i].style.display="";
	}
	doFilterStateChange1();
}
//************End Pkg Quick Search*************//			
//************Start Class Quick Search*************//			
function quickFilterClassList(){
	var term = document.getElementById("cls_searchbox").value;
	var clList = document.getElementById("classlistoutline");
	var x = clList.getElementsByTagName("a");
	var clsFoundCount = 0;
	term = term.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
	var patt1 = new RegExp(term,"i");
	for(i=0;i<x.length;i++){
		var pstr;
		if(x[i].textContent){
			pstr = x[i].textContent.replace(/^\s\s*/, '').replace(/\s\s*$/, '').match(patt1);
		}else{
			pstr = x[i].innerText.replace(/^\s\s*/, '').replace(/\s\s*$/, '').match(patt1);
		}
		
		if(x[i].className == "noqsearch"){
			x[i].style.display = "none";
		}else if(pstr != null && pstr.length>0 && x[i].style.display != "none"){
			clsFoundCount++;
			var iterm = x[i].innerHTML;
			x[i].innerHTML = iterm.replace(pstr[0],"<span class='clsHighlightText'>"+pstr[0]+"</span>");
		}else{
			if(x[i].id == "cls_name" || x[i].id == "cls_clear_search"){
				//x[i].style.display = "";
			}else{
				x[i].style.display = "none";
			}
		}
	}
	
	if(clsFoundCount == 0){
		var ctxtdoc = document.getElementById("cls_txtMsg");
		if(ctxtdoc == null){
			var aCls = document.createElement("div");
			aCls.id = "cls_txtMsg";
			aCls.innerHTML = qsearchText;
			bCls = document.getElementById("classlistoutline");
			bCls.appendChild(aCls);
		}
	}
}
function clsSearchBoxOnFocus(){
	var inputDiv = document.getElementById("cls_searchbox");
	//alert(inputDiv.value);
	if(inputDiv.value==inputDiv.defaultValue){
		inputDiv.value='';
		inputDiv.style.color='rgb(0, 0, 0)';
	}
}


function clsSearchOnKeyUp(){
	if(getCookie("showAllClasses") ==null || getCookie("showAllClasses")=="no" || getCookie("showAllClasses")==""){
		if(loadAllClassesRan != 1){
			saveAllClassesView("more");
		}
	}
	if(allClassesLoaded){
		clsSearchOnKeyUp1();
	}
}
function clsSearchOnKeyUp1(){
	var inputDiv = document.getElementById("cls_searchbox");
		if(inputDiv.value==''){
			document.getElementById('cls_clear_search').className = 'search_inactive';
		}else{
			document.getElementById('cls_clear_search').className = 'search_active';
		}
		var len = document.getElementById("cls_searchbox").value.length;
		//alert(len);
		if(len>=2){
			clsClearHighlight();
			quickFilterClassList();
		}else{
			clsClearHighlight();
		}
}
function clsSearchBoxOnBlur(){
	var inputDiv = document.getElementById("cls_searchbox");
	if(inputDiv.value==''){
		inputDiv.value=inputDiv.defaultValue;
		inputDiv.style.color='rgb(170, 170, 170)';
		document.getElementById('cls_clear_search').className='search_inactive';
	}
}
function clsClearSearchButton(){
	document.getElementById("cls_searchbox").value='';
	document.getElementById("cls_searchbox").focus();
	clsClearHighlight();
	document.getElementById('cls_clear_search').className = 'search_inactive';
}

function clsClearHighlight(){
	var clList = document.getElementById("classlistoutline");
	x = [];
	var tNode = document.getElementById("cls_txtMsg");
	if( document.getElementById("cls_txtMsg") != null){
		pNode = document.getElementById("classlistoutline");
		pNode.removeChild(tNode);
	}
	if(navigator.userAgent.search("MSIE") >=0){
		xtemp = clList.getElementsByTagName("span");
		j=0;
		for(i=0;i<xtemp.length;i++){
			if(xtemp[i].className == "clsHighlightText"){
				x[j] = xtemp[i];
				j++;
			}
		}
		for(i=0;i<x.length;i++){
			y = x[i].parentNode;
			z = x[i].innerHTML;
			txtNode = document.createTextNode(z);
			x[i].appendChild(txtNode);
			y.replaceChild(txtNode,x[i]);
		}
	}else{
		x = clList.getElementsByClassName("clsHighlightText");
		while(x.length>0){
			y = x[0].parentNode;
			z = x[0].innerHTML;
			txtNode = document.createTextNode(z);
			x[0].appendChild(txtNode);
			y.replaceChild(txtNode,x[0]);
		}
	}

	//making all the anchor tags visible
	var alinks = clList.getElementsByTagName("a");
	for(i=0;i<alinks.length;i++){
		alinks[i].style.display="";
	}
	doFilterStateChange1();
}

function getInternetExplorerVersion() {
    var rv = -1; // Return value assumes failure.
    if (navigator.appName == 'Microsoft Internet Explorer') {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}


//************End Class Quick Search*************//					
